package com.lightdz.tshirtdz.controller;

import com.lightdz.tshirtdz.bll.ReceiveAddrBll;
import com.lightdz.tshirtdz.model.api.ApiReceiveAddr;
import com.lightdz.tshirtdz.model.api.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ Description：收货地址接口
 * @ Author     ：zbl
 * @ Date       ：Created in 16:03 09/08/2018
 * @ Modified By：
 */
@RestController
@RequestMapping(value = "/receiveaddr")
public class ReceiveAddrController {

    @Autowired
    ReceiveAddrBll addrBll;
    /**
     * 获取我的收货地址
     */
@GetMapping(value = "/getMyAddrList")
public ApiResponse<List<ApiReceiveAddr>> getMyAddrList(String wxId){
return  addrBll.getMyAddrList(wxId);
}
    /**
     * 修改我的收货地址
     */
    @GetMapping(value = "/updateAddr")
    public ApiResponse<Boolean> updateAddr(long addrId, boolean isDefault, String receiver, String receiverTel, String regionAddr, String wxId, String streetAddr){
        return  addrBll.updateAddr(addrId,isDefault,receiver,receiverTel,regionAddr,wxId,streetAddr);
    }

    /**
     * 添加收货地址
     * @param isDefault
     * @param receiver
     * @param receiverTel
     * @param regionAddr
     * @param wxId
     * @param streetAddr
     * @return
     */
    @GetMapping(value = "/addAddr")
    public ApiResponse<Boolean> addAddr(boolean isDefault,String receiver,String receiverTel,String regionAddr,String wxId,String streetAddr){
        return addrBll.addAddr(isDefault,receiver,receiverTel,regionAddr,wxId,streetAddr);
    }


    @GetMapping(value = "/deleteAddr")
    public ApiResponse<Boolean> deleteAddr(int addrId){
        return addrBll.deleteAddr(addrId);
    }
}
